package com.tianyuchan.exception.exception;

import com.tianyuchan.exception.enums.ContractManageErrorCode;

import java.math.BigDecimal;

/**
 * @Classname : ContractManageAssert
 * @Description : 合同管理业务断言
 * @Author : cty
 * @Date 2023/3/19 20:27
 */


public class ContractManageAssert {

    public static void isTrue(boolean expression, ContractManageErrorCode errorCode, Object... args) {
        if (!expression) {
            throw new ContractManageException(errorCode, args);
        }
    }

    public static void isEquals(Integer num1, Integer num2, ContractManageErrorCode errorCode) {
        if (num1.compareTo(num2) != 0) {
            throw new ContractManageException(errorCode, num1, num2);
        }
    }

    public static void isLessThanOrEqualTo(BigDecimal num1, BigDecimal num2, ContractManageErrorCode errorCode) {
        if (num1.compareTo(num2) > 0) {
            throw new ContractManageException(errorCode, num1, num2);
        }
    }

}
